﻿using System;
using System.Reflection;
using System.Web.UI;
using Besture.Common;

namespace Besture.UI.Admin.Control
{
    public partial class ListButtonControl : BaseControl
    {
        public string Title { get; set; }

        protected void Page_Load(object sender, EventArgs e)
        {
            if(!string.IsNullOrEmpty(Title))
            {
                lbAdd.Text = "添加" + Title;
            }
        }

        /// <summary>
        /// 转向添加页面
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="eventArgs"></param>
        protected void btnAdd_Click(object obj, EventArgs eventArgs)
        {
            Response.Redirect(SetUrl());
        }

        /// <summary>
        /// 删除选中数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnDel_Click(object sender, EventArgs e)
        {
            //获得父页面
            Page p =this.Parent.Page;
            Type pageType = p.GetType();
            //调取父页面的方法名
            MethodInfo mi = pageType.GetMethod("DeleteSelect");
            mi.Invoke(p, new object[] { });
        }
    }
}